/*
Copyright (C) 1996-1997 Id Software, Inc.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/

#include "quakedef.h"
#include "menu.shared.h"

char *quitMessage[] =
{
	/* .........1.........2.... */
	"Are you gonna quit",
	"this game just like",
	"everything else?",
	"",

	"Milord, methinks that",
	"thou art a lowly",
	"quitter. Is this TRUE?",
	"",

	"Do I need to bust your",
	"face open for trying",
	"to quit?",
	"",

	"Man, I oughta smack you",
	"for trying to quit!",
	"Press Y to get",
	"smacked out.",

	"Press Y to quit like a",
	"big loser in life.",
	"Press N to stay proud",
	"and successful!",

	"If you press Y to",
	"quit, I will summon",
	"Satan all over your",
	"hard drive!",

	"Um, Asmodeus dislikes",
	"his children trying to",
	"quit. Press Y to return",
	"to your Tinkertoys.",

	"If you quit now, I'll",
	"throw a blanket-party",
	"for you next time!",
	""
};


class qmenu_quit_t : public qmenu_t
{
public:
	qmenu_quit_t (void)
	{
		this->Register (m_quit);
	}

	void EnterFunc (void)
	{
		if (m_state == m_quit)
			return;

		wasInMenus = (key_dest == key_menu);
		m_quit_prevstate = m_state;

		this->EnterMenu ();

		// make the message time-based
		msgNumber = (int) (realtime * 10.0) & 7;

		// switch the sound (as a cool little easter egg)
		m_soundlevel = m_sound_quit;
	}

	BOOL KeyFunc (int key)
	{
		switch (key)
		{
		case 'n':
		case 'N':
		case K_ESCAPE:
			this->LeaveMenu ();
			break;

		case 'Y':
		case 'y':
			Key_SetDest (key_console);
			Host_Quit_f ();
			break;

		default:
			break;
		}

		return TRUE;
	}

protected:
	void CustomDraw (void)
	{
		if (wasInMenus)
		{
			m_state = m_quit_prevstate;
			m_recursiveDraw = TRUE;
			M_Draw ();
			m_state = m_quit;
		}

		// expand by 4 pixels in each dir to reduce quake's "everything scrunched tightly against everything else" shittiness
		M_DrawTextBox (48, 72, 25, 5);

		// center vertically
		int y = (quitMessage[msgNumber * 4 + 3][0]) ? 84 : 88;

		// center horizontally
		for (int i = 0; i < 4; i++)
		{
			char *str = quitMessage[msgNumber * 4 + i];
			int len = strlen (str);

			if (str[0]) M_Print ((320 - len * 8) >> 1, y + 8 * i, str);
		}
	}

private:
	int		msgNumber;
	m_state_t	m_quit_prevstate;
	BOOL	wasInMenus;
} menu_quit;


